Hi,

I had a similar problem and tried to find the best way to handle the problem, without mixing  JavaScript and jsp syntax.  What I came up with was a series of select boxes, some of which were dependant on others, that changed their values based on the selection made in a different select box.  I have a series of select boxes that call the submit method everytime a change is made.  Calling the submit method in the onchange event handler, means that the form posts itself every time selection is made.  I can then track which of the select boxes was changed, read the new value, which has just been submitted and populate the other lists based on the newly changed value.  This is an example of what I mean.

Within jsp page.

<html:form action="/archive.do"> 
    <bean:message key="select.title.seasons" />
    <html:select property="season" onchange="submit()">
        <html:options property="value" collection="seasonsList" />
    </html:select><br/><br/> 
  

   <html:hidden property="option" value="season" />
   <html:hidden property="action" value="Populate" />
</html:form>  
 
 <html:form action="/archive.do">
     <bean:message key="select.title.oppositions" />
     <html:select property="opposition" onchange="submit()">
          <html:options property="value" collection="oppositionsList" />
     </html:select><br/><br/>    
     <html:hidden property="option" value="opposition" />
     <html:hidden property="action" value="Populate" />
 </html:form> 

Within perform method:

String action = <form instance>.getAction();   // action set by hidden variable in jsp page

String option = <form-instance>.getOption(); // option set by hidden variable in jsp page

if the action is equal to the action specified in the form's hidden variable and option is equal to option specified in the forms hidden variable, then retrieve the selected value of the first select box and populate the arrayList of options for the second select box.

I hope this makes sense.

Chiji.

 

>From: Robin Whitley <[EMAIL PROTECTED]>

>Reply-To: [EMAIL PROTECTED]
>To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
>Subject: struts selection and Javascript onchange question
>Date: Tue, 28 Aug 2001 23:25:50 -0400
>MIME-Version: 1.0
>Received: from [64.125.133.20] by hotmail.com (3.2) with ESMTP id MHotMailBD55ABD5004540043217407D85140B790; Tue, 28 Aug 2001 20:26:13 -0700
>Received: (qmail 11536 invoked by uid 500); 29 Aug 2001 03:24:58 -0000
>Received: (qmail 11524 invoked from network); 29 Aug 2001 03:24:58 -0000
>Received: from greensboro.bondisoftware.com (216.54.174.133) by daedalus.apache.org with SMTP; 29 Aug 2001 03:24:58 -0000
>Received: by COSMO with Internet Mail Service (5.5.2653.19)id ; Tue, 28 Aug 2001 23:25:51 -0400
>From struts-user-return-16241-cn081 Tue, 28 Aug 2001 20:27:23 -0700
>Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
>Precedence: bulk
>list-help:
>list-unsubscribe:
>list-post:
>Delivered-To: mailing list [EMAIL PROTECTED]
>Message-ID: <3125D8065A0AD411A90A009027B11742058942@COSMO>
>X-Mailer: Internet Mail Service (5.5.2653.19)
>X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N
>
>I have a form that has a selection box for country. If "UNITED STATES" is
>selected, the form has a stateProvince selection box that should be
>populated with "state" options. If "CANADA" is selected, the stateProvince
>selection box should be populated with the "province" options. I use
>struts_logic:equal based on the "country" bean property
>to accomplish this. The form populates the struts_html:options from a
>collection. The logic works properly if there is an initial value for
>country. However, when the country option is changed, the onchange event
>does not appear to fire the javascript function fillStateProvince.
>
>What I tried to do in the fillStateProvince function was to test the
>selected option for country, and set the value on the bean, hoping that this
>would set my struts_html:options properly. My sysouts indicate that when
>the form loads, it sets the country value to UNITED STATES and then to
>CANDADA, but that when I change country, the function doesn't fie.
>
>I've included the pertinent code. My question, is this the proper way to
>handle this or is there a better way to accomplish the same result.
>Does anybody see anything silly that I am doing in the Javascript, or struts
>logic that is causing this result.
>
>Any help would be appreciated.
>
>
>Thanks,
>
>Robin Whitley
>
>
><% -- Javascript -- %>
>
><%@ page language="Java" contentType="text/html; charset=UTF-8"
>errorPage="error.jsp" %>
>
>
>
>
>
>
>
><%-- In the form - country -- %>
>
>
> >labelProperty="label" />
>
>
>
><%-- In the form - stateProvince -- %>
>
>
>
>
> >value="UNITED STATES">
>
>
>
> >labelProperty="label" />
>
>
>
> >value="CANADA">
>
>
> >property="value" labelProperty="label" />
>
>
>
>


Get your FREE download of MSN Explorer at http://explorer.msn.com